<?php
/**
 * Created by PhpStorm.
 * User: 王松
 * Time: 2017/6/13 17:38
 */

namespace App\Transformers;

use Illuminate\Database\Eloquent\Model;
use League\Fractal\TransformerAbstract;

class DiseaseDictionaryTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['detail'];

    /**
     * @param \Illuminate\Database\Eloquent\Model $dictionary
     * @return array
     */
    public function transform(Model $dictionary)
    {
        return [
            'id'   => $dictionary->id,
            'name' => $dictionary->name,
            'icd'  => $dictionary->icd,
        ];
    }

    /**
     * 返回信息中加入诊断的详细信息
     * @param \Illuminate\Database\Eloquent\Model $dictionary
     * @return \League\Fractal\Resource\Item
     */
    public function includeDetail(Model $dictionary)
    {

        return $this->item($dictionary, function (Model $dictionary) {

            return [];

        });
    }
}